package HomeWork.Demo02;

public class Student {
    private String name;
    private char sex;
    private int age;
    public Student() {
    }
    public Student(String name, char sex, int age) {
        this.name = name;
        this.sex = sex;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public char getSex() {
        return sex;
    }

    public void setSex(char sex) {
        this.sex = sex;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString(){
        return "{" +
                "name:"+name+"\n" +
                "sex:"+sex+"\n" +
                "age"+age+"\n" +
                "}";
    }
}

class text{
    public static void main(String[] args) {
        Student s1=new Student("小明",'男',16);
        System.out.println(s1.toString());

        Student s2=new Student("小明",'男',16);
        System.out.println(s2.toString());

        Student s3=new Student("小明",'女',16);
        System.out.println(s3.toString());

        if(isSame(s1,s2)){
            System.out.println("是相同的");
        }
        if(!isSame(s1,s3)){
            System.out.println("不是相同的");
        }

    }
    private static boolean isSame(Student s1,Student s2){
        if(s1.getName().equals(s2.getName())&&s1.getSex()==s2.getSex()&&s1.getAge()==s2.getAge()){
            return true;
        }
        return false;
    }
}
